package icg;

import java.util.HashMap;
import java.util.Set;
import java.util.Vector;

public class ICG {
	public HashMap<Integer, Vector<Quadruple>> quadrupleMap;
	public Vector<Quadruple> tableQuadruple;
	private Integer lastTableId;

	public ICG() {
		this.quadrupleMap = new HashMap<Integer, Vector<Quadruple>>();
	}

	public void gen(Quadruple q) {
		quadrupleMap.get(lastTableId).add(q);
	}

	public Vector<Quadruple> newQuadrupleTable(Integer cod) {
		Vector<Quadruple> qt = new Vector<Quadruple>();
		lastTableId = cod;
		quadrupleMap.put(cod, qt);
		return qt;
	}

	/*public void insert(Integer pos, Vector<Quadruple> listQuadruple) {
		quadrupleMap.put(pos, listQuadruple);
	}*/

	/*public Vector<Quadruple> get(Integer pos) {
		return quadrupleMap.get(pos);
	}*/

	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		Set<Integer> keys = quadrupleMap.keySet();
		for (Integer key : keys) {
			Vector<Quadruple> list = quadrupleMap.get(key);
			for (Quadruple q : list) {
				sb.append(key + " -> " + q).append("\n");
			}
		}
		return sb.toString();
	}
}
